package com.choosefine.base.shixiaobao.device.service;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.choosefine.base.shixiaobao.base.BaseService;
import com.choosefine.base.shixiaobao.common.def.CommonConstant;
import com.choosefine.base.shixiaobao.device.dao.DeviceInfoMapper;
import com.choosefine.base.shixiaobao.device.model.DeviceInfo;

@Service("DeviceInfoService")
public class DeviceInfoService extends BaseService {
	@Autowired
	DeviceInfoMapper deviceInfoMapper;
	
	public DeviceInfo getDeviceInfoById(Integer id) throws Exception {
		return deviceInfoMapper.selectByPrimaryKey(id);
	}
	
	public Integer save(DeviceInfo deviceInfo) throws Exception {
		return deviceInfoMapper.insert(deviceInfo);
	}
	
	public Integer update(DeviceInfo deviceInfo) throws Exception {
		return deviceInfoMapper.updateByPrimaryKeySelective(deviceInfo);
	}
	
	/*
	 * @category 逻辑删除
	 */
	public Integer delete(Integer id) throws Exception {
		DeviceInfo info = new DeviceInfo();
		info.setId(id);
		info.setIsValid(CommonConstant.INVALID);
		return deviceInfoMapper.updateByPrimaryKeySelective(info);
	}
}
